package com.idroid.dialogs;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.idroid.R;

public class HelpDialog extends DialogFragment {

	private Activity activity;
	private String text;
	private String title;

	public static HelpDialog newInstance(Activity activity, String title,
			String text) {

		HelpDialog dialog = new HelpDialog();
		dialog.activity = activity;
		dialog.text = text;
		dialog.title = title;

		return dialog;
	}

	public View createDialogView() {
		View v = activity.getLayoutInflater().inflate(R.layout.help_dialog,
				null);

		TextView textView = (TextView) v.findViewById(R.id.helpText);
		textView.setText(text);

		return v;
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		final View v = createDialogView();

		return new AlertDialog.Builder(getActivity()).setTitle(title)
				.setView(v).setPositiveButton("OK", null).create();
	}
}
